class Bullet extends Spirit {
  constructor(x = 0, y = 0) {
    super('img/bullet.png')
    this.speed = 5
    this.x = x
    this.y = y
  }

  update() {
    this.y -= this.speed

    if (this.y < 0) {
      this._scene.remove(this)
    }

    this.checkhit()

  }

  checkhit() {
    if (!this._scene.enemies) {
      return
    }
    this._scene.enemies.forEach(e => {
      if (utils.intersect(this, e)) {
        this.attack(e)
      }
    })
  }

  attack(enemy) {
    this._scene.removeEnemy(enemy)
    this._scene.remove(this)
  }
}